
<%@ include file="checkLogin.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: l
  Date: 2022/5/26
  Time: 17:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE>
<html>
<head>
    <title>管理后台</title>
    <link href="./css/admin.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="header">
    <div id="welcome">欢迎使用新闻管理系统！</div>
    <div id="nav">
        <div id="logo"><img src="./images/logo.jpg" alt="新闻中国"/></div>
        <div id="a_b01"><img src="./images/a_b01.gif" alt=""/></div>
    </div>
</div>

<div id="admin_bar">
    <div id="status">
        管理员：${currentUser.uname} 登录 &#160;&#160;&#160;&#160;
        <a href="logout.jsp">login out</a>
        当前在线的有${fn:length(currentUserList)} 个人:
        <c:forEach var="newsUsers" items="${currentUserList}">
            <a href="#">${newsUsers.uname}</a>
        </c:forEach>
    </div>
    <div id="channel"></div>
</div>
<div id="main">
    <div id="opt_list">
        <ul>
            <li><a href="news_add.jsp">添加新闻</a></li>
            <li><a href="#">编辑新闻</a></li>
            <li><a href="#">查找新闻</a></li>
            <li><a href="topic_add.jsp">添加主题</a></li>
            <li><a href="topicList.jsp">编辑主题</a></li>
            <li><a href="productList.jsp">购买商品</a></li>
            <li><a href="updateUser.jsp">修改个人资料</a></li>
        </ul>
    </div>
    <div id="opt_area">
        <script src="./js/jquery-3.6.0.js"></script>
        <script>
            $(function () {
                $("#form1").submit(function () {
                    if ($("#ntid").val() === -1) {
                        alert("请选择主题!");
                        return false;
                    }
                    if ($("#ntitle").val() === "") {
                        alert("请填写标题!");
                        return false;
                    }
                    if ($("#nauthor").val() === "") {
                        alert("请填写作者!");
                        return false;
                    }
                    if ($("#nsummary").val() === "") {
                        alert("请填写摘要!");
                        return false;
                    }
                    if ($("#ncontent").val() === "") {
                        alert("请填写内容!");
                        return false;
                    }
                })
            })
        </script>
        <ul>
            <h3>修改新闻</h3>
            <form id="form1" action="EditNewsServlet" method="post">
                <input type="hidden" name="nid" id="nid" value="${news.nid}">
                <p>主题:
                    <select name="ntid" id="ntid">
                        <option value="-1">请选择</option>
                        <c:forEach var="topic" items="${listTopic}">
                        <option <c:if test="${topic.tid==news.ntid}"> selected</c:if> value="${topic.tid}">${topic.tname}</option>
                        </c:forEach>
                    </select>
                </p>
                <p>
                    标题: <input type="text" id="ntitle" name="ntitle" value="${news.ntitle}">
                </p>
                <p>
                    作者: <input type="text" id="nauthor" name="nauthor" value="${news.nauthor}">
                </p>
                <p>
                    摘要: <textarea name="nsummary" id="nsummary" cols="30" rows="5">${news.nsummary}</textarea>
                </p>
                <p>
                    内容: <textarea name="ncontent" id="ncontent" cols="30" rows="10">${news.ncontent}</textarea>
                </p>
                <p>
                    上传图片: <input type="file" name="">
                </p>
                <input type="submit" value="提交">
                <input type="reset" value="重置">
            </form>
        </ul>
    </div>
</div>
<div id="site_link">
    <a href="">关于我们</a><span>|</span>
    <a href="">Aboue Us</a><span>|</span>
    <a href="">联系我们</a><span>|</span>
    <a href="">广告服务</a><span>|</span>
    <a href="">供稿服务</a><span>|</span>
    <a href="">法律声明</a><span>|</span>
    <a href="">招聘信息</a><span>|</span>
    <a href="">网站地图</a><span>|</span>
    <a href="">留言反馈</a>
</div>
</body>
</html>
